/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package gradius.Elementos.Tiros;

import gradius.Elementos.Coordenada;
import gradius.Elementos.TelaGrafica;
import java.awt.Graphics2D;
import java.awt.Image;

/**
 *
 * @author Eduardo
 */
public class TiroAnimado extends Tiro
{
    private int incr;
    private int indice;
    private Image[] imagens;

    public TiroAnimado(TelaGrafica tela, Image[] imagens, int coordX, int coordY, int sentidoX, int sentidoY, int tamX, int tamY)
    {
        super(tela,coordX,coordY,sentidoX,sentidoY,tamX,tamY);
        this.imagens = imagens;
        this.indice = 0;
        this.incr = 1;
    }

    @Override
    public void desenha(Graphics2D g2)
    {
        Coordenada coord = new Coordenada(0,0);
        coord = this.getElementoCoordenada();
        g2.drawImage(imagens[indice], coord.getCoordX(), coord.getCoordY(), tela);
        indice += incr;
        if (indice == 0 || indice == imagens.length - 1)
        {
            incr = -incr;
        }
    }
}
